Skip to content

fix(agc): preserve registered array slices on CPU write-back - #6367

Merged
adriadam10 merged 1 commit into
boykopovar:mainfrom
Zenodeon:stk-rendering-correctness
Oct 19, 2026
Merged

adriadam10 merged 1 commit into
boykopovar:mainfrom
Zenodeon:stk-rendering-correctness

Conversation

@Zenodeon

@Zenodeon Zenodeon commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

What

Preserve GPU results during CPU write-back when the selected texture-array slice is registered but unused slices in the descriptor extend outside registered memory.

For example, only slice 0 of a four-slice array may be registered and have pending results. StorageTexture::writeBackLayers previously checked registration of the entire declared image and discarded slice 0's valid results because the unused slices were unregistered. It also refreshed unsaved guest bytes outside the ranges being stored.

Validate each retained write-back range instead, and intersect unsaved snapshot reads with those ranges. Keep the existing overhang handling and drop behavior when an actual destination has been unregistered. No public API or shader-semantic changes; no title-specific checks.

The regression registers only the first or last slice while keeping the complete backing allocation mapped. It checks the drawn pixels and untouched unused slices. A separate retirement case unregisters the active allocation before flushing and verifies that no stale results are written.

SuperTuxKart PPSA69421 supplied real two-slice descriptors whose active first slice fits its registered allocation while the entire descriptor does not. This PR does not claim a title unblock, a black-rendering correction, or a performance improvement.

Related work checked before publication: #6202 scopes refresh and adds independent coverage in the same test file; #6197 changes import selection, including within writeBackLayers; #6280 changes mip handling within that function; #6246 adds an allocation lease for idle stores. None implements this retained-range registration check or snapshot-read intersection. These are independent mechanisms; retain their changes and this regression when reconciling textual conflicts. No dependency on those PRs or the shader experiment tracked by #1413.

Tested

Based on upstream main 73e924a; PR commit 540c3a1.

Windows (10.0.26200), Intel Core i7-13700, 32 GiB RAM, NVIDIA RTX 4070 12 GiB, driver 591.86. GCC 15.2.0, Ninja, Release, BUILD_TESTING=ON, ANYPS5_ENABLE_SPIRV_TOOLS=ON; checked-out submodule revisions match the repository gitlinks. Rebuilt the complete libs target and focused test binaries; preserved a complete 126-library runtime snapshot with SHA-256 hashes locally.

  • Before: with the new regression and upstream's original production Texture.cpp, agc_driver_array_layer_target fails in 1.56 s:
    CPU write-back discarded the registered slice because an unused array slice was unregistered
    
  • After: 14/14 focused tests pass in 17.25 s total, each under 30 s, with ANYPS5_GPU=RTX 4070 and ANYPS5_REQUIRE_VULKAN=1:
    • agc_storage_kept_unit_settle, agc_storage_upload_lifetime, agc_storage_upload_failure, agc_storage_split_writeback, agc_host_import_retirement, agc_storage_cpu_snapshot;
    • agc_driver_graphics, agc_driver_array_layer_target, agc_driver_depth_fast_clear, agc_driver_depth_fast_clear_submit, agc_driver_depth_storage, agc_driver_depth_storage_reuse, agc_driver_storage_one_slice_alias, agc_driver_storage_write_back_overhang.
  • python tools/check_conventions.py --base upstream/main and git diff --check upstream/main...HEAD pass; tracked working tree clean.

Remaining validation: fresh standalone SuperTuxKart and vkQuake baseline/candidate comparisons, a completed race, controls/audio checks on this candidate, and a 15-minute stability run. Earlier successful interactive rendering/controls/audio used a separate experimental runtime and are not acceptance evidence for this PR. Linux, lavapipe and other GPU vendors have not been tested locally. No speed claim or performance acceptance result.

Checklist

  • Based on current main; no other open PR implements the same fix (related function/file overlap listed above)
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt (no comments added)
  • Unimplemented paths retain strict failure behavior; no silent stubs added
  • No notes, investigation .md files, images, logs or game files added to the repository
  • New third-party code is a submodule built from source (none added)
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Unblocks: none claimed; regression workload SuperTuxKart PPSA69421
  • GPUs tested: NVIDIA RTX 4070, driver 591.86, Windows 10.0.26200
  • AI-assisted: yes (OpenAI Codex)

Extended validation remains pending; this PR makes no title-unblock or performance claim.

This was referenced Oct 15, 2026
@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 6202 core/libs/prx/libSceAgcDriver/tests/execution/ArrayLayerTarget.cpp L311
PR 6960 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp L5143-5145

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 1368 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 1395 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 4448 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 5609 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6188 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6192 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6197 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6280 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6454 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6457 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6479 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6481 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6539 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6615 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6683 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6730 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6946 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6947 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6971 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6977 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 7154 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 7254 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 7256 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 7604 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 7642 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp

@romainveurrier

Copy link
Copy Markdown

Heads-up from #6960 : it also changes writeBackLayers' read of unsaved guest bytes on the CPU path. It moves the read before the keep decision, because the store now uses a compare-exchange against those bytes, and reading them after the decision lets a CPU store made in between pass as the expected value. Your PR can go first; I'll rebase and keep your registered-range restriction, applied to that earlier read.

@github-actions github-actions Bot added the unblocks title Names a title ID on the Unblocks line label Oct 18, 2026
@adriadam10 adriadam10 self-assigned this Oct 18, 2026
@adriadam10
adriadam10 merged commit 659230f into boykopovar:main Oct 19, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* unblocks title Names a title ID on the Unblocks line

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants